import os
import pandas as pd

# 测试矩阵数据
data = {
    "用例编号": ["TC001", "TC002", "TC003", "TC004", "TC005"],
    "测试类型": ["负向", "负向", "负向", "SQL注入", "正向"],
    "用户名": ["admin", "1234567890asdfghjk", "admin_9131", "' OR 1=1 --", "admin_9131"],
    "密码": ["admin", "adimin", "1251xasxiashdiashdiasdhasiudhasiudhasdasdasdasd", "admin", "admin"],
    "测试说明": ["无效用户名密码（示例）", "账号名过长", "密码过长", "SQL注入攻击尝试", "正常登录"],
    "预期结果": [
        "登录失败，提示用户名或密码错误",
        "登录失败，提示用户名或密码错误",
        "登录失败，提示用户名或密码错误",
        "登录失败，系统安全无漏洞",
        "登录成功，进入主界面"
    ]
}

# 创建 DataFrame
df = pd.DataFrame(data)

# 创建文件夹
folder = "D:\\pycharm\\PM_test\\Excel"
if not os.path.exists(folder):
    os.makedirs(folder)

# 写入 Excel
file_path = os.path.join(folder, "login_test_matrix.xlsx")
df.to_excel(file_path, index=False, sheet_name="登录功能测试矩阵")

print(f"测试矩阵已保存到：{file_path}")
